package com.darren.archive.component;

import com.darren.archive.service.SysParameterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class SysParameterHelper {
	
	public static final String SYSTEM_CONFIG = "SYSTEM_CONFIG";

	public static final String TOKEN_CONFIG = "TOKEN_CONFIG";
	
	private static SysParameterService sysParameterService;
	
	@Autowired
    public void setSystemService(SysParameterService systemParameterService) {
		SysParameterHelper.sysParameterService = systemParameterService;
    }
	
	/************************************************* SYSTEM CONFIG *************************************************/
	public static final String getEncryptKey() {
		return sysParameterService.getSysParamVal(SYSTEM_CONFIG, "encrypt_key");
	}

	public static final Integer getPageSize() {
		return sysParameterService.getSysParamVal(SYSTEM_CONFIG, "pageSize",Integer.class);
	}

	/************************************************ TOKEN CONFIG *************************************************/
	public static final long getAccessTokenExpire() {
		return sysParameterService.getSysParamVal(TOKEN_CONFIG, "ACCESS_TOKEN_EXPIRES_TIME",long.class);
	}

	public static final long getRefreshTokenExpire() {
		return sysParameterService.getSysParamVal(TOKEN_CONFIG, "REFRESH_TOKEN_EXPIRES_TIME",long.class);
	}

	public static final String getAccessTokenSecureSecret() {
		return sysParameterService.getSysParamVal(TOKEN_CONFIG, "ACCESS_SECURE_SECRET");
	}

	public static final String getRefreshTokenSecureSecret() {
		return sysParameterService.getSysParamVal(TOKEN_CONFIG, "REFRESH_SECURE_SECRET");
	}

	/**
	 * 从系统参数表中获取Token签发者
	 * @return
	 */
	public static final String getTokenIssuer() {
		return sysParameterService.getSysParamVal(TOKEN_CONFIG, "TOKEN_ISSUER");
	}

}
